package com.xzh.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQTopicConfig {
    /*public static final String queue1 = "queue1_topic";
    public static final String queue2 = "queue2_topic";
    public static final String exchange = "exchange_topic";
    public static final String binding1 = "queue.*";
    public static final String binding2 = "queue.#";

    @Bean
    public Queue queue1()
    {
        return new Queue(queue1);
    }
    @Bean
    public Queue queue2()
    {
        return new Queue(queue2);
    }
    @Bean
    public TopicExchange exchange()
    {
        return new TopicExchange(exchange);
    }
    @Bean
    public Binding binding1()
    {
        return BindingBuilder.bind(queue1()).to(exchange()).with(binding1);
    }
    @Bean
    public Binding binding2()
    {
        return BindingBuilder.bind(new Queue(queue2)).to(new TopicExchange(exchange)).with(binding2);
        //return BindingBuilder.bind(queue2()).to(exchange()).with(binding2);
    }*/
    public static final String QUEUE = "seckillQueue";
    public static final String EXCHANGE = "seckillExchange";
    @Bean
    public Queue queue()
    {
        return new Queue(QUEUE);
    }
    @Bean
    public TopicExchange exchange()
    {
        return new TopicExchange(EXCHANGE);
    }
    @Bean
    public Binding binding()
    {
        return BindingBuilder.bind(queue()).to(exchange()).with("seckill.#");
    }

}
